﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using EmbeddedSharp.Core.Logging;
using WeifenLuo.WinFormsUI.Docking;

namespace Zove.Desktop {
    public partial class MessageForm : DockContent {

        public static MessageForm Instance {
            get;
            set;
        }

        public MessageTabPageCollection Pages {
            get;
            set;
        }

        public MessageForm() {
            InitializeComponent();

            Pages = new MessageTabPageCollection(this.tabControl1.TabPages);
            //this.FormClosed += new FormClosedEventHandler(MessageForm_FormClosed);
        }

        public void MessageForm_FormClosed(object sender, EventArgs e) {
            Instance = null;
        }

        public void ShowMessages(
            string tabName, List<LoggingMessage> messages) {
            TabPage page = this.Pages[tabName];

            MessageGridView messageGridView 
                = (MessageGridView)page.Controls["MessageGridView"];
            messageGridView.Messages = messages;
            messageGridView.BindMessages();
        }
    }
}
